package com.buli.blmall.admin.system.controller;

import org.springframework.web.bind.annotation.*;
import com.buli.blmall.admin.system.service.SysRoleMenuService;
import com.buli.blmall.admin.system.vo.SysRoleMenuVO;
import com.buli.blmall.admin.base.BaseController;
import com.buli.blmall.admin.common.response.Result;
import java.util.List;
import lombok.AllArgsConstructor;


/**
 * <p>
 * 角色菜单 控制器
 * </p>
 *
 * @author buli
 * @since 2025-02-27
 */
@RestController
@RequestMapping("system/sys_role_menu")
@AllArgsConstructor
public class SysRoleMenuController extends BaseController {

    private SysRoleMenuService sysRoleMenuService;

    /**
     * 查询角色菜单详情
     *
     * @param id 角色菜单ID
     */
    @GetMapping("/{id}")
    public Result<SysRoleMenuVO> getsysRoleMenu(@PathVariable Long id) {
        return Result.success(sysRoleMenuService.info(id));
    }

    /**
     * 查询角色菜单集合
     *
     * @param sysRoleMenuVo
     */
    @GetMapping("/list")
    public Result<List<SysRoleMenuVO>> listSysRoleMenu(SysRoleMenuVO sysRoleMenuVo) {
        return Result.success(sysRoleMenuService.queryList(sysRoleMenuVo));
    }

    /**
     * 添加角色菜单
     * @param sysRoleMenuVo
     */
    @PostMapping("/add")
    public Result<Boolean> addSysRoleMenu(@RequestBody SysRoleMenuVO sysRoleMenuVo) {
        return Result.success(sysRoleMenuService.add(sysRoleMenuVo));
    }

    /**
     * 修改角色菜单
     * @param sysRoleMenuVo
     */
    @PutMapping("/edit")
    public Result<Boolean> editSysRoleMenu(@RequestBody SysRoleMenuVO sysRoleMenuVo) {
        return Result.success(sysRoleMenuService.edit(sysRoleMenuVo));
    }

    /**
     * 删除角色菜单
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> removeSysRoleMenu(@PathVariable Long id) {
        return Result.success(sysRoleMenuService.removeById(id));
    }

}

